#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
ll a[N];
ll tot;
ll ans;
void dfs(int s, int k, ll res) {
  if (s + k == n + 1) {
    rep(i, s, n) res ^= a[i];
    ans = max(ans, res ^ tot);
    return;
  }
  if (s == n + 1 || !k) {
    ans = max(ans, res ^ tot);
    return;
  }
  rep(i, s, n + 1 - k) { dfs(i + 1, k - 1, res ^ a[i]); }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) cin >> a[i];
  if (m * 2 > n) {
    rep(i, 1, n) tot ^= a[i];
    m = n - m;
  }
  dfs(1, m, 0);
  cout << ans;
  return 0;
}